window.addEventListener('load',function(){
    var text = document.querySelector('.text')
    var btn = document.querySelector('button')
    var ul = document.querySelector('ul')
    btn.addEventListener('click',function(){
        if(text.value==''){
            return false
        }else{
            var li = document.createElement('li')
            li.innerHTML  = text.value + '<a href="javascript:;">删除</a>'
            text.value = ''
            ul.insertBefore(li,ul.children[0])
            
            var as = document.querySelectorAll('a')
            for(var i=0;i<as.length;i++){
                as[i].addEventListener('click',function(){
                    ul.removeChild(this.parentNode)
                })
            }
        }
    })
})